import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/users/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/users/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/users/logout',
    method: 'post'
  })
}

/**
 * 获取用户列表
 * @param {*} query
 */
export function listUsers(query) {
  return request({
    url: '/users',
    method: 'get',
    params: query
  })
}

/**
 * 删除用户
 * @param {*} data
 */
export function deleteUsers(id) {
  return request({
    url: 'users',
    method: 'delete',
    params:{id}
  })
}

/**
 *
 * @param {添加员工} data
 * @returns
 */
export function saveUsers(data) {
  return request({
    url: '/users',
    method: 'post',
    data
  })
}

/**
 *
 * @param {编辑员工} data
 * @returns
 */
export function editUsers(data) {
  return request({
    url: '/users',
    method: 'put',
    data
  })
}

export function getByIdUser(id) {
  return request({
    url: '/users/detail',
    method: 'get',
    params: {id}
  })
}


